home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 November / EnigmA AMIGA RUN 02 (1995)(G.R. Edizioni)(IT)[!][issue 1995-11][Skylink CD].iso / earcd / program / amos / amcafext.lha / AMCAF_Examples / Protracker.AMOS / Protracker.amosSourceCode < prev    next >
AMOS Source Code  |  1995-07-14  |  7KB  |  202 lines

  1. ' ************************************* Commands used: 
  2. ' *                                   * Imploder Load      Blitter Clear 
  3. ' *           Amcaf Examples          * Pt Cia Speed       Turbo Draw
  4. ' *      Protracker Commands V1.1     * Pt Volume          Blitter Fill
  5. ' *      Written by Chris Hodges      * Pt Voice           =Lsstr$ 
  6. ' *                                   * Pt Play            =Lsr
  7. ' ************************************* =Pt Vu 
  8. '                          
  9. ' Hide the mouse cursor, because we need sprite 0. 
  10. Hide 
  11. ' Load some music. 4 Spirits is a tune by Alexander Kunz. Thx for it! :) 
  12. ' Music must be loaded into chipmem, so the banknumber has to be negativ.
  13. ' The music file has been file imploded to save a mere 72 KB of valuable 
  14. ' disk space.
  15.  Extension_8_0EA2 "Data/mod.4spirits",-3
  16. '�Open a 4 colours screen. 
  17. Screen Open 0,320,256,4,Lowres
  18. Curs Off : Flash Off : Paper 0 : Pen 1 : Cls 
  19. ' Copy the sprite palette to the right place.
  20. Get Sprite Palette 
  21. For A=0 To 15 : Colour A+16, Colour(A) : Next 
  22. ' Set screen palette 
  23. Palette $8,$FFF,$8,$FF8
  24. ' Turn on double buffering.
  25. Double Buffer 
  26. Autoback 1
  27. ' Create a nice copper bar.
  28. Set Rainbow 0,1,64,"","",""
  29. For A=0 To 63
  30.   Rain(0,A)=Max(Min(A/3-8,15),0)*$10+Min(A/2,15)*$100+Max(Min(A/2-15,15),0)
  31. Next 
  32. Rainbow 0,0,Y Hard(191),64
  33. ' Dim a field to hold the current vumeter state. 
  34. Dim VU(3)
  35. ' Another field is needed for some boring text.
  36. Dim TXT$(13)
  37. ' TXT$() is filled now filled with text. 
  38. For A=1 To 13
  39.   Read TXT$(A)
  40. Next 
  41. ' Print the speed counter. =Lsstr$ is used to make a formatted string. 
  42. BPM=125
  43. Pen 1 : Locate 0,16 : Print "Current speed: "; Extension_8_0EC8(BPM,3)+" bpm."
  44. Print "To change use cursor left/right."
  45. ' Print the volume control-text. 
  46. VOL=64
  47. Pen 1 : Locate 0,19 : Print "Current volume: "; Extension_8_0EC8(VOL,2)
  48. Print "To change press cursor up/down."
  49. ' Print toggles. To keep it as simple as possible, I reserve a field which 
  50. ' holds the two channel states (on or off), and then look, if the bit
  51. ' is set in the channel mask.
  52. Dim TG$(1)
  53. TG$(0)="Off" : TG$(1)="On "
  54. VOI=%1111
  55. For C=0 To 3
  56.   Locate 0,8+C : Print "Channel";C+1;": "+TG$( Extension_8_093A(VOI,C) and 1)
  57. Next 
  58. Print : Print "Press 1,2,3,4 to toggle channels."
  59. ' Now follow some sprite definitions for the drums.
  60. ' Sorry, but I'm not a graphic artist, and I do apologize the low-quality
  61. ' Sprites :) 
  62. HITHIHAT$="(1,1)(2,1)(1,1)(3,1)(1,2)(2,2)(1,3)(3,3)(1,1)"
  63. OPENHIHAT$="(4,3)(5,3)(1,1)"
  64. HITBASS$="(12,3)(13,3)(14,3)(11,3)"
  65. HITSNARE$="(15,3)(16,3)(17,3)(11,3)"
  66. HITBOTH$="(18,3)(19,3)(20,3)(11,3)"
  67. CLAP$="(7,1)(8,1)(9,1)(10,1)(6,1)"
  68. ' Now display the sprites and assign them to the channels. 
  69. Sprite 0,X Hard(112),Y Hard(64),1
  70. Channel 0 To Sprite 0
  71. Sprite 2,X Hard(128),Y Hard(64),11
  72. Channel 1 To Sprite 2
  73. Sprite 6,X Hard(176),Y Hard(64),6
  74. Channel 2 To Sprite 6
  75. ' Set the music to cia-timing. 
  76.  Extension_8_10F2 BPM
  77. ' Turn up the volume to maximum. 
  78.  Extension_8_10C6 VOL
  79. ' Turn on all voices.
  80.  Extension_8_10D6 VOI
  81. ' And finally, start playing.  
  82.  Extension_8_108E 3
  83. Repeat 
  84.   ' Check the keyboard.
  85.   I$=Inkey$
  86.   ' Check for the keys 1 to 4. 
  87.   If I$=>"1" and I$<="4"
  88.     ' Get the channelnumber. I don't use the Val-Function, because it does not 
  89.     ' work correctly when compiled.
  90.     C=Asc(I$)-Asc("1")
  91.     ' Change the bit C in the voice mask.
  92.     Bchg C,VOI
  93.     Pen 1
  94.     Locate 0,8+C : Print "Channel";C;": "+TG$( Extension_8_093A(VOI,C) and 1)
  95.      Extension_8_10D6 VOI
  96.   End If 
  97.   ' Has cursor-down been pressed?  
  98.   If I$=Cdown$ and VOL>0
  99.     ' Then make it softer. 
  100.     Dec VOL
  101.     Pen 1 : Locate 16,19 : Print Extension_8_0EC8(VOL,2)
  102.      Extension_8_10C6 VOL
  103.   End If 
  104.   ' Has cursor-up been pressed?
  105.   If I$=Cup$ and VOL<64
  106.     ' Then make it louder. 
  107.     Inc VOL
  108.     Pen 1 : Locate 16,19 : Print Extension_8_0EC8(VOL,2)
  109.      Extension_8_10C6 VOL
  110.   End If 
  111.   ' Has cursor-left been pressed?
  112.   If I$=Cleft$ and BPM>32
  113.     ' Then decrement speed.
  114.     Dec BPM
  115.     Pen 1 : Locate 15,16 : Print Extension_8_0EC8(BPM,3)
  116.      Extension_8_10F2 BPM
  117.   End If 
  118.   ' Has cursor-right been pressed? 
  119.   If I$=Cright$ and BPM<255
  120.     ' Then increase speed. 
  121.     Inc BPM
  122.     Pen 1 : Locate 15,16 : Print Extension_8_0EC8(BPM,3)
  123.      Extension_8_10F2 BPM
  124.   End If 
  125.   ' Clear the old vumeters from the screen.
  126.    Extension_8_121C 0,0,16,190 To 304,256
  127.   For A=0 To 3
  128.     ' Look if there's a new note.
  129.     VU= Extension_8_10E6(A)
  130.     ' Yes? Then set the vumeter to the new value 
  131.     If VU Then VU(A)=VU
  132.     ' Draw two horizontal lines. the vertical lines are not needed.
  133.      Extension_8_1016 A*80+24,255-VU(A) To A*80+24,255,1
  134.      Extension_8_1016 A*80+56,255-VU(A) To A*80+56,255,1
  135.     ' Decrement the height of the vumeter bar. 
  136.     VU(A)=Max(VU(A)-2,0)
  137.   Next 
  138.   ' Fill the four vumeters.
  139.    Extension_8_1042 0,0,16,190,304,256
  140.   ' Look if some event has occured.
  141.   P= Extension_8_10B6 
  142.   ' Yes? Then examine the signal.
  143.   If P
  144.     ' Print the value, and fade it out.
  145.     Home : Pen 2 : Print "Pt Signal: ";Hex$(P,2)
  146.     Colour 2,$FF0
  147.     Fade 4,$8,$FFF,$8
  148.     ' If the signal is from 1 to 16, it will be used to print out some text. 
  149.     If P<16
  150.       Pen 3 : Locate 0,3 : Cline : Print TXT$(P)
  151.     End If 
  152.     ' Is it in the range from 16 to 32, it represents one of the drums.
  153.     If P>15 and P<32
  154.       ' Hit the hihat, when signal 16,18 or 20 appeared. 
  155.       If P=16 or P=18 or P=20
  156.         Anim 0,HITHIHAT$ : Anim On 0
  157.       End If 
  158.       ' Open it, if signal 17 was sent.
  159.       If P=17
  160.         Anim 0,OPENHIHAT$ : Anim On 0
  161.       End If 
  162.       ' Bassdrum on 18 and 20
  163.       If P=18 or P=20
  164.         Anim 1,HITBASS$ : Anim On 1
  165.       End If 
  166.       ' Snaredrum on 21
  167.       If P=21
  168.         Anim 1,HITSNARE$ : Anim On 1
  169.       End If 
  170.       ' And both snare and bass on 22
  171.       If P=22
  172.         Anim 1,HITBOTH$ : Anim On 1
  173.       End If 
  174.       ' Clap hands when signal is 19 or 20.
  175.       If P=19 or P=20
  176.         Anim 2,CLAP$ : Anim On 2
  177.       End If 
  178.     End If 
  179.   End If 
  180.   ' Swap screens.
  181.   Screen Swap 
  182.   Wait Vbl 
  183. Until I$=Chr$(27) or Mouse Key
  184.  Extension_8_10A8 
  185. Amal Off 
  186. Sprite Off 
  187. Screen Close 0
  188. Rainbow Del : View : Wait Vbl 
  189. End 
  190. Data "Yeah!!!"
  191. Data "These are AMCAF..."
  192. Data "Protracker commands..."
  193. Data "The text appears..."
  194. Data "in perfect synchro with the music!"
  195. Data "You can control all your effects..."
  196. Data "directly from within the music! Cool!"
  197. Data "Dumdidum... :)))"
  198. Data "Just watch the vumeters... "
  199. Data "And enjoy the music..."
  200. Data "Music by Neurodancer/Abyss."
  201. Data "Sorry, but I'm too lazy to fill in..."
  202. Data "some more commands. Fin!"